function rv = fvdisc(sd,md,price,disc,basis)
%FVDISC Future value of discounted security.
%   Finds the amount received at maturity RV for a fully vested security
%   given the settlement date SD, the maturity date MD, present value
%   PRICE, discount rate DISC, and day-count basis BASIS.
%
%   rv = fvdisc(sd,md,price,disc)
%   rv = fvdisc(sd,md,price,disc,basis)
%
%   Enter dates as serial date numbers or date strings.
%
%   Inputs:
%       SD      -  Settlement date
%       MD      -  Maturity date
%       PRICE   -  Price
%       DISC    -  Discount rate
%
%   Optional Inputs:
%       basis   -  the day-count basis:
%                  0 = actual/actual (default)
%                  1 = 30/360 SIA
%                  2 = actual/360
%                  3 = actual/365
%                  4 = 30/360 PSA
%                  5 = 30/360 ISDA
%                  6 = 30E/360
%                  7 = actual/365 Japanese
%                  8 = actual/actual ISMA
%                  9 = actual/360 ISMA
%                 10 = actual/365 ISMA
%                 11 = 30/360 ISMA
%                 12 = actual/365 ISDA
%                 13 = bus/252
%
%   Using the following data,
%
%   SD = '02/15/1991'
%   MD = '05/15/1991'
%   PRICE = 100
%   DISC = .0575
%   BASIS = 2
%
%   $101.44 is returned at maturity of the security.
%
%   See also ACRUDISC, PRDISC, YLDDISC.
%
%   Reference: Mayle, Standard Securities Calculation Methods, Volumes
%              I-II, 3rd edition.

%       Copyright 1995-2006 The MathWorks, Inc.
%       $Revision: 1.6.2.8 $   $Date: 2009/05/07 18:23:26 $

if nargin < 5
    basis = zeros(size(price));
end

if nargin < 4
    error('finance:fvdisc:notEnoughInputs',...
        'Missing one of SD, MD, PRICE, and DISC.');
end

[~, sd, md, ~, basis, ~, ~, ...
    ~, ~, ~, ~] = ...
    instargbond([],sd,md,[],basis,[],[],[],[],[],[]);

[sd,md,price,disc,basis] = ...
    finargsz(1,sd,md,price,disc,basis);

% Formulas 1 and 2
rv = reshape(price./(1-disc.*yearfrac(sd,md,basis)),size(price));